package com.rhb.af.web.screen.bean;

import java.util.ArrayList;
import java.util.List;


public class Select {
	private String name;
	private List options;

	public Select(){
		name = "";
		options = new ArrayList();
	}
	
	public Select(Select select){
		name = new String(select.getName());
		options = new ArrayList();
		for(int i=0; i<select.getOptions().size(); i++){
			options.add(new Option((Option)select.getOptions().get(i)));
		}
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List getOptions() {
		return options;
	}

	public void setOptions(List options) {
		this.options = options;
	}
	
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append("Select[name=" + name +",");
		for(int i=0; i<options.size(); i++){
			sb.append(((Option)options.get(i)).toString());
		}
		sb.append("]");
		return sb.toString();
	}
	
	public String getOptionLabel(String optionValue){
		String str = "";
		for(int i=0; i<options.size(); i++){
			Option o = (Option)options.get(i);
			if(o.getValue().equals(optionValue)){
				str = o.getLabel();
				break;
			}
		}
		return str;
	}
	
}
